int* nextGreaterElement(int* nums1, int nums1Size, int* nums2, int nums2Size, int* returnSize) {
    *returnSize = nums1Size;
    int* a = (int*)malloc(sizeof(int) * nums1Size);
    int g = 0, temp = 0;
    for (int i = 0; i < nums1Size; i++)
    {
        int flag = 1;
        temp = nums1[i];
        for (int j = 0; j < nums2Size; j++)
        {

            if (nums2[j] == temp)
            {
                for (g = j + 1; g < nums2Size; g++)
                {
                    if (nums2[g] > temp)
                    {
                        flag = 0;
                        break;
                    }
                }
            }
            if (flag == 0)
            {
                break;
            }
        }
        if (flag == 0)
        {
            a[i] = nums2[g];
        }
        else
        {
            a[i] = -1;
        }
    }
    return a;
}